<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head><meta HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8"/>
<title>如何在JSP里使用查询</title><link href="../zdoc.css" rel="stylesheet" type="text/css"/>
</head>
<body><a name="top"></a>
<div class="zdoc_header">如何在JSP里使用查询</div>
<div class="zdoc_author"><em>By:</em><b>Jaron</b></div>
<div class="zdoc_body">
<ul class="zdoc_index_table">
<li>
<div><span class="num">1</span><a href="#使用方法">使用方法</a></div>
</li>
</ul>
<div class="hr"><b></b></div>
<h1><a name="使用方法"></a>使用方法</h1>
<div style="float:right;"><a href="#top">Top</a></div>
<p>在jsp里导入标签库</p>
<pre>&lt;%@ taglib prefix="utils" uri="http:<span class="zdoc_code_cmt">//www.jaronsource.org/tags/utils" %&gt;
</span></pre>
<p>查询对象列表</p>
<pre>&lt;utils:query jpql="select o from Contact o where o.name like :name " var="contactList"&gt;
	&lt;utils:queryParam name="name" value="zhang" /&gt;
&lt;/utils:query&gt;

&lt;c:forEach items="${contactList}" var="entry"&gt;
	${entry.name}
&lt;/c:forEach&gt;
</pre>
<p>查询对象</p>
<pre>&lt;utils:queryOne jpql="select o from Contact o where o.name like :name " var="contact"&gt;
	&lt;utils:queryParam name="name" value="zhang" /&gt;
&lt;/utils:queryOne&gt;

${contact.name}
</pre>
</div>
<div class="zdoc_footer"><em>By:</em><b>Jaron</b></div>
</body>
</html>